package com.jnsjcc.freemarker.service;


import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.springframework.stereotype.Service;

import com.jnsjcc.freemarker.model.ChildEntity;
import com.jnsjcc.freemarker.model.TestEntity;

@Service
public class EntityService {
    
    Date createDate;
    
    public EntityService(){
        createDate = new Date();
    }
    
    
    
    //创建一个entity
    public TestEntity getEntity(){
        List<ChildEntity> childList = new ArrayList<>();
        
        childList.add(new ChildEntity("child1", createDate, false, "sssssssssssssssssssssssssssssssssssssssss"));
        childList.add(new ChildEntity("child2", new Date(), true, "sssssssssssssssssssssssssssssssssssssssss"));
        childList.add(new ChildEntity("child3", createDate, false, "sssssssssssssssssssssssssssssssssssssssss"));
        childList.add(new ChildEntity("child4", new Date(), true, "sssssssssssssssssssssssssssssssssssssssss"));
        childList.add(new ChildEntity("child5", createDate, false, "sssssssssssssssssssssssssssssssssssssssss"));
        
        return new TestEntity("name1", createDate, false, "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", childList);       
        
    }
    
    
    
    //创建一个entity的List
    public List<TestEntity> getList(){
        List<TestEntity> entityList = new ArrayList<>();
        for(int i = 0; i <= 10; i++){
            List<ChildEntity> childList = new ArrayList<>();
            childList.add(new ChildEntity("child1", createDate, false, "sssssssssssssssssssssssssssssssssssssssss"));
            childList.add(new ChildEntity("child2", new Date(), true, "sssssssssssssssssssssssssssssssssssssssss"));
            childList.add(new ChildEntity("child3", createDate, false, "sssssssssssssssssssssssssssssssssssssssss"));
            childList.add(new ChildEntity("child4", new Date(), true, "sssssssssssssssssssssssssssssssssssssssss"));
            childList.add(new ChildEntity("child5", createDate, false, "sssssssssssssssssssssssssssssssssssssssss"));
            entityList.add(new TestEntity("name"+i, new Date(), i % 3 == 0, "xxxxxxxxxxxxxxxxxxxxxxx", childList));
            
        }
        
        return entityList;
    }

}
